import request from '@/utils/request'

// 获取图书列表
export const getBookList = (params) => {
  return request({
    url: '/books',
    method: 'get',
    params
  })
}

// 获取图书详情
export const getBookDetail = (id) => {
  return request({
    url: `/books/${id}`,
    method: 'get'
  })
}

// 创建图书
export const createBook = (data) => {
  return request({
    url: '/books',
    method: 'post',
    data
  })
}

// 更新图书
export const updateBook = (id, data) => {
  return request({
    url: `/books/${id}`,
    method: 'put',
    data
  })
}

// 删除图书
export const deleteBook = (id) => {
  return request({
    url: `/books/${id}`,
    method: 'delete'
  })
}

// 批量删除图书
export const batchDeleteBooks = (ids) => {
  return request({
    url: '/books/batch',
    method: 'delete',
    data: { ids }
  })
}

// 搜索图书
export const searchBooks = (params) => {
  return request({
    url: '/books/search',
    method: 'get',
    params
  })
}

// 获取热门图书
export const getPopularBooks = (params) => {
  return request({
    url: '/books/popular',
    method: 'get',
    params
  })
}

// 获取最新图书
export const getLatestBooks = (params) => {
  return request({
    url: '/books/latest',
    method: 'get',
    params
  })
}